package com.bailian.system.utils;

import java.util.List;
import java.util.ArrayList;
import java.util.stream.Collectors;
import com.bailian.system.domain.*;
import com.bailian.system.domain.vo.BLWareHouseVo;
import org.springframework.stereotype.Component;

/**
 * 仓库VO转换工具类
 * 
 * @author bailian
 * @date 2025-08-04
 */
@Component
public class WarehouseVoConverter {
    
    /**
     * 将BlWarehouse转换为BLWareHouseVo
     * 
     * @param blWarehouse 仓库实体
     * @return 仓库VO
     */
    public BLWareHouseVo convertToVo(BlWarehouse blWarehouse) {
        if (blWarehouse == null) {
            return null;
        }
        
        BLWareHouseVo vo = new BLWareHouseVo();
        
        // 复制基本属性
        vo.setWarehouseId(blWarehouse.getWarehouseId());
        vo.setWarehouseName(blWarehouse.getWarehouseName());
        vo.setDescription(blWarehouse.getDescription());
        vo.setAddress(blWarehouse.getAddress());
        vo.setAreaSize(blWarehouse.getAreaSize());
        vo.setFloorLoad(blWarehouse.getFloorLoad());
        vo.setFloorHeight(blWarehouse.getFloorHeight());
        vo.setPlatformCount(blWarehouse.getPlatformCount());
        vo.setEquipmentConfig(blWarehouse.getEquipmentConfig());
        vo.setHardwareConfig(blWarehouse.getHardwareConfig());
        vo.setFireLevel(blWarehouse.getFireLevel());
        vo.setFireFacilities(blWarehouse.getFireFacilities());
        vo.setSecurity(blWarehouse.getSecurity());
        vo.setAdditionalServices(blWarehouse.getAdditionalServices());
        vo.setAddressDesc(blWarehouse.getAddressDesc());
        vo.setRentalPrice(blWarehouse.getRentalPrice());
        vo.setVrLink(blWarehouse.getVrLink());
        vo.setThumbnailUrl(blWarehouse.getThumbnailUrl());
        vo.setIsRecommend(blWarehouse.getIsRecommend());
        vo.setCreateTime(blWarehouse.getCreateTime());
        vo.setUpdateTime(blWarehouse.getUpdateTime());
        vo.setIndustryDataId(blWarehouse.getIndustryDataId());
        vo.setBannerPage(blWarehouse.getBannerPage());

        // 直接设置仓库标签列表
        vo.setWarehouseTags(blWarehouse.getWarehouseTags());

        return vo;
    }
    
    /**
     * 将BlWarehouse列表转换为BLWareHouseVo列表
     * 
     * @param blWarehouseList 仓库实体列表
     * @return 仓库VO列表
     */
    public List<BLWareHouseVo> convertToVoList(List<BlWarehouse> blWarehouseList) {
        if (blWarehouseList == null || blWarehouseList.isEmpty()) {
            return new ArrayList<>();
        }
        
        return blWarehouseList.stream()
            .map(this::convertToVo)
            .collect(Collectors.toList());
    }
    

} 